package com.zrwl.poscloud.commons.fallback;

import com.zrwl.poscloud.commons.feign.ServerCenterFeignClient;
import com.zrwl.poscloud.commons.holder.RequestHolder;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 商户服务器中心微服务降级兜底方法【当服务不可用时会触发】
 *
 * @author: liusitong
 * @create: 2020-10-03-20:54
 */
@Component
@Slf4j
public class ServerCenterFeignFallback implements ServerCenterFeignClient {

    @Override
    public String proxyRequest(String serverType, String companyCode, String meJsonStr, String requestUrl, String requestHeaderStr, String requestParamStr) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("商户服务器中心微服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取商户服务器中心微服务降级返回");
    }

}
